<template>
	<view class="type_con">
		<!-- 广告图 -->
		<view class="type_banner">
			<image src="../../static/t01.png" mode="widthFix"></image>
		</view>
		<!-- 垃圾分类 -->
		<view class="types">
			<view :class="{'active':isActive == item.id}" @click="select(item)" v-if="item.pricejson" v-for="item in list">{{item.name}}</view>
		</view>
		<!-- 可回收&不可回收 -->
		<view class="types_info">
			<view class="price-extra">(常州区域,仅供参考,各城市由于当地市场原因价格有所浮动)</view>
			<view>
				<view class="priceList" v-for="item,index in detail" v-if="item">
					<view>
						<image src="../../static/scar.png" mode="heightFix"></image>
					</view>
					<view>
						{{index}}车
					</view>
					<view>
						<image src="../../static/priceIcon.png" mode="widthFix"></image>
						<text>{{item}}/车</text>
					</view>
				</view>
				<!-- <view class="priceList">
					<view>
						<image src="../../static/mcar.png" mode="heightFix"></image>
					</view>
					<view>
						20吨车
					</view>
					<view>
						<image src="../../static/priceIcon.png" mode="widthFix"></image>
						<text>900元/车</text>
					</view>
				</view> -->
			</view>
		</view>
		<!-- 操作 -->
		<view class="operate" @click="toOrder()">
			<view>立即预约</view>
		</view>
	</view>
</template>	

<script>
	export default {
		data() {
			return {
				isActive: 1,
				list:[],
				detail:{}
			}
		},
		onLoad(options) {
			var that = this;
			console.log(options.typeNum);
			if(options.typeNum && options.typeNum!='') {
				that.isActive = options.typeNum
			}
			this.getList()
		},
		methods: {
			select(item) {
				this.isActive = item.id;
				this.detail = JSON.parse(item.pricejson)
			},
			toOrder() {
				uni.setStorageSync('classId', 15)
				uni.switchTab({
					url:"/pages/appointment/appointment"
				})
			},
			getList(){
				this.$get('release/releasetype', {
					first_id: 14
				}, (res) => {
					console.log(res)
					this.list = res;
					this.$get('release/releasetype', {
						first_id: 15
					}, (res) => {
						console.log(res)
						this.list = this.list.concat(res);
						this.list.some(item=>{
							if(item.pricejson){
								this.select(item)
							}
							return !!item.pricejson
						})
					})
				})
				
			}
		}
	}
</script>

<style>
	page {
		background: #ffffff;
	}
	.type_banner image {
		width: 100%;
	}
	.types {
		/* background: #e6e6e6; */
		/* display: flex; */
		/* justify-content: flex-start; */
		/* align-items: center; */
		width: 730rpx;
		height: 54rpx;
		margin-left: 10rpx;
		border-bottom: 6rpx solid #d54f09;
		overflow-x: auto;
		white-space: nowrap;
	}
	.types view {
		/* width: 50%; */
		text-align: center;
		font-size: 20rpx;
		font-weight: bold;
		color: #fff;
		height: 48rpx;
		width: 160rpx;
		line-height: 48rpx;
		background: linear-gradient(#f8cf5f,#f7b44c,#f69034);
		display: inline-block;
	}
	.types view.active {
		background: linear-gradient(#f77734,#f56113,#dd530a);
	}
	
	.types_info image {
		width: 100%;
	}
	.operate view {
		width: 500rpx;
		margin: 50rpx auto 20rpx;
		height: 86rpx;
		line-height: 86rpx;
		border: 1px solid #00bb66;
		background: #00bb66;
		border-radius: 20rpx;
		color: #fff;
		font-size: 48rpx;
		font-weight: bold;
		text-align: center;
	}
	.price-extra {
		font-size: 20rpx;
		color: #585858;
		text-align: center;
		padding: 22rpx 0;
	}
	.priceList {
		width: 690rpx;
		margin: 0 auto 30rpx;
		height: 150rpx;
		box-shadow: 1px 1px 9px 5px #efefef;
		display: flex;
		justify-content: space-around;
		align-items: center;
	}
	.priceList:first-child {
		border-left: 30rpx solid #8ccd3f;
	}
	.priceList view:first-child image {
		height: 60rpx;
	}
	.priceList view:last-child image {
		width: 38rpx; 
		height: 38rpx;
		vertical-align: sub;
		margin-right: 10rpx;
	}
	.priceList:last-child {
		border-left: 30rpx solid #f7b64e;
	}
</style>
